From: Daniel van Vugt Date: Wed, 22 Jan 2020 08:40:50 +0000 (+0800) Subject: dnd: Make DND translation-property-aware X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~777^2^2~165 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=881eab766959af1dcf1b73119dd478b891957cdb;p=gnome-shell.git dnd: Make DND translation-property-aware Previously DND only worked properly for actors with zero translation. But it only requires a small tweak to `this._dragOffsetX/Y` to support non-zero translation values. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/936 --- diff --git a/js/ui/dnd.js b/js/ui/dnd.js index cc2f360b5..cb72737f1 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -411,14 +411,18 @@ var _Draggable = class _Draggable { this._snapBackY = this._dragStartY + this._dragOffsetY; this._snapBackScale = this._dragActor.scale_x; + let origDragOffsetX = this._dragOffsetX; + let origDragOffsetY = this._dragOffsetY; + let [transX, transY] = this._dragActor.get_translation(); + this._dragOffsetX -= transX; + this._dragOffsetY -= transY; + if (this._dragActorMaxSize != undefined) { let [scaledWidth, scaledHeight] = this._dragActor.get_transformed_size(); let currentSize = Math.max(scaledWidth, scaledHeight); if (currentSize > this._dragActorMaxSize) { let scale = this._dragActorMaxSize / currentSize; let origScale = this._dragActor.scale_x; - let origDragOffsetX = this._dragOffsetX; - let origDragOffsetY = this._dragOffsetY; // The position of the actor changes as we scale // around the drag position, but we can't just tween @@ -435,8 +439,8 @@ var _Draggable = class _Draggable { this._dragActor.get_transition('scale-x').connect('new-frame', () => { let currentScale = this._dragActor.scale_x / origScale; - this._dragOffsetX = currentScale * origDragOffsetX; - this._dragOffsetY = currentScale * origDragOffsetY; + this._dragOffsetX = currentScale * origDragOffsetX - transX; + this._dragOffsetY = currentScale * origDragOffsetY - transY; this._dragActor.set_position( this._dragX + this._dragOffsetX, this._dragY + this._dragOffsetY);